import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
import _createClass from "@babel/runtime/helpers/esm/createClass";
import _inherits from "@babel/runtime/helpers/esm/inherits";
import _createSuper from "@babel/runtime/helpers/esm/createSuper";
import React from 'react';
import { connect } from 'dva';
import { Table } from 'antd';
import { Header, Content } from "../../components/Page";
import intl from "../../utils/intl";

var GlobalException = /*#__PURE__*/function (_React$Component) {
  _inherits(GlobalException, _React$Component);

  var _super = _createSuper(GlobalException);

  function GlobalException() {
    _classCallCheck(this, GlobalException);

    return _super.apply(this, arguments);
  }

  _createClass(GlobalException, [{
    key: "getColumns",
    value: function getColumns() {
      return [{
        title: intl.get('cpaas.common.message.errorMessage').d('错误信息'),
        dataIndex: 'errorMessage'
      }, {
        title: intl.get('cpaas.common.message.errorLocation').d('错误页面'),
        dataIndex: 'errorLocation'
      }];
    }
  }, {
    key: "render",
    value: function render() {
      var exceptionHistory = this.props.exceptionHistory;
      var exceptionColumns = this.getColumns();
      return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Header, {
        backPath: "/workplace",
        title: intl.get('cpaas.common.message.globalError').d('很抱歉！出现预料之外的错误')
      }), /*#__PURE__*/React.createElement(Content, null, /*#__PURE__*/React.createElement(Table, {
        rowKey: function rowKey(record, index) {
          return index;
        },
        bordered: true,
        columns: exceptionColumns,
        dataSource: exceptionHistory,
        pagination: false,
        rowSelection: null
      })));
    }
  }]);

  return GlobalException;
}(React.Component);

export default connect(function (_ref) {
  var _ref$error = _ref.error,
      error = _ref$error === void 0 ? {} : _ref$error;
  var _error$globalExceptio = error.globalException;
  _error$globalExceptio = _error$globalExceptio === void 0 ? {} : _error$globalExceptio;
  var _error$globalExceptio2 = _error$globalExceptio.history,
      history = _error$globalExceptio2 === void 0 ? [] : _error$globalExceptio2;
  return {
    exceptionHistory: history
  };
})(GlobalException);